HSIMSimulator for Amateur Hybrid Rocket MotorsVersion 0.2 Stephen Daniel September 4, 2006 IntroductionHsim is intended as a physically and mathematically precise simulator for simple hybrid rocket motors that use self-pressurized liquid N2O as an oxidizer and one of a small set of solids as the fuel. The input is text file that describes the simulation. The output is a text file that can be post-processed into a summary report or into an engine data file for Rocksim version 8. At present the models assume the tank is a cylinder and that the fuel grain is a cylinder (i.e. has a single port). The assumption of self-pressurized nitrous is pretty baked into the model, but the other simplifying assumptions are lightly used and could probably be changed without much difficulty. This pre-release version of the simulator is intended for use by people who have substantial knowledge of small hybrid motor design. As-Is UsageThis simulator has been somewhat tested and appears to give reasonable results over a useful range of inputs. However, the authors make no warranty of correctness or even reasonableness. Use of a simulator does not substitute for proper testing of a motor design. WarrantyBECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. LicensingHsim and related components are distributed in source form under a GPL license. The full text of the license can be viewed by running hsim -l Revision HistorySeptember 4, 2006: Hsim 0.2
July 1, 2006: Hsim 0.1
Theory of OperationHsim simulates the operation of a self-pressurized nitrous hybrid using straightforward numerical techniques. Each time-step involves these steps:
The Nitrous Tank ModelThe tank model is built using thermodynamic data from the U.S National Institute of Standards. The model assumes that the nitrous tank is always in equilibrium. Essentially, the model believes that the temperature of nitrous does not vary throughout the tank and that the liquid and gas phases are in thermodynamic equilibrium, a condition known as saturation. The model has available a summary of the NIST data that covers the properties of saturated nitrous from 250o K to 310o K (approximately -10o F to 98o F). Any attempt to operate the nitrous tank outside this temperature data will cause the simulator to abort. The initial conditions inside the tank can be set one of two ways. The simulation control file may either specify an initial flight-tank pressure, or the temperature of the supply tank and the estimated pressure drop may be supplied. The tank is assumed to be vented through a small vent, as is standard for most amateur hybrid motors. The vent model is based on Suttons formulas for cold-gas thrusters. The tank model solves for equilibrium temperature and pressure using a simple iterative technique. The ratio of liquid to gaseous nitrous is computed for the known mass and volume at the current temperature. The total enthalpy of the nitrous is computed. If the calculated enthalpy does not match the known enthalpy of the nitrous the temperature is adjusted. This calculation is repeated until the tank state converges. The Combustion Chamber ModelThe combustion chamber model is built using simple physical models of the combustion chamber and the nozzle, augmented by propellant chemistry data computed by CPROPEP. The calculation is iterative, adjusting the chamber pressure up or down until the chamber comes into equilibrium. The iteration loop involves these steps:
The combustion chamber model contains two fudge-factors to account for less-than-ideal behavior. The first is a C* adjustment. The C* returned by CPROPEP is adjusted downward by a multiplicative factor to account for combustion inefficiencies. Such inefficiencies are caused by incomplete combustion, possibly due to poor chamber or injector design. In addition, the simulator adjusts the nozzle Cf by a formula that brings the Cf closer to 1.0 by a fraction. This fraction attempts to account for imperfections in the nozzle due to poor shape. Time Step and Error ControlHsim has an extremely simple time-step mechanism. The models assume that all flows (nitrous vent, nitrous injector, and fuel regression) are constant during the time step. Time steps are fixed at a user-specified period. All testing has been with a 1 millisecond time step. Obviously far more sophisticated means exist for high-performance numerical integration. Such methods can also estimate and bound errors. However, experience has shown the simulator as written is fast enough. The curves are all smooth enough that we believe error control is not a serious issue. Systematic errors in the physical models are presumed to dominate over numerical errors by an order of magnitude or more. Effects Not ModeledHsim’s models do not account for a number of physical effects. At a minimum, these include:
Other Limitations
All of these limitations could easily be removed. InstructionsHsim is a simple batch program designed to run in a UNIX system environment. It was developed primarily under Cygwin, but we’ve run it on Linux as well. We expect that porting Hsim to an arbitrary UNIX system would be trivial. Hsim is a simple batch program. It reads an input file specifying the simulation to run and generates an output file with the results of the simulation. Input File FormatThe input file specifies a number of numerical parameters for the simulator. Here is a sample input file:
Each line has three fields. The first field is the name of the parameter. Parameters may be specified in any order. Parameter names are case sensitive. The second field is the parameter value. If the parameter is a physical quantity, then the third field specifies the unit of measure. The fields are separated by arbitrary amounts of white space. Blank lines and lines beginning with a ‘#’ are ignored. In theory anything after ‘#’ on any line is ignored, but there may be bugs with the input parser that prevent proper processing of comments that do not begin at the beginning of the line. The list of legal units can be found by examining the source file scio.c. Input ParametersThis table lists the input parameters that may be specified in the input file.
Output File FormatThe output of the simulator is an ascii file full of numbers. This file is post-processed by the report generator to produce human-readable output. No documentation of the file format is available, but you can probably figure it out by looking at one of the files. Command Line InvocationHsim is intended to be run from a command line prompt. Under Windows the easiest way to get such a prompt is to click on the start button, click “run…” and enter “cmd”. This should give you a dos prompt. Type cd <dir> where <dir> is the directory containing hsim. Hsim is intended to be invoked as follows:
Theoretically, Hsim needs to run CPROPEP on every iteration as the combustion chamber state is computed, and this must be recomputed on every time step. Actually invoking CPROPEP on each chamber calculation would make the program run extremely slowly. In order to speed up operation, Hsim relies on the fact that CPROPEP has only 4 relevant input parameters, the fuel type, the nozzle exit to throat ratio, the chamber pressure, and the oxidizer to fuel ratio. Two of these (fuel and nozzle ratio) do not change during a run of the simulator. At the start of a simulation run, Hsim loads in a mesh of CPROPEP computed data points. For this run’s nozzle ratio and fuel, the mesh provides a number of data points at different O/F ratios and chamber pressures. Intermediate values between the data points are interpolated. For a typical 2GHz computer, CPROPEP requires about 2 minutes of compute to create the mesh. Since typical design problems require multiple simulations using only a small set of fuel/nozzle ratio combinations, the results of this CPROPEP calculation are stored on disk. Normally hsim will refuse to run if cached CPROPEP results are not available. Providing hsim with the “–N exec” command line option allows it to invoke CPROPEP as needed. The report generator reads the simulator output file and generates a report. If a –r <filename> option is provided to the report generator it will also create a rocksim engine data file in <filename>. This file can be used by Rocksim version 8 to simulate a rocket with the simulated hybrid engine. InstallationHsim is shipped in source form. It has been successfully compiled and run under Linux and the Cygwin emulation environment under windows. Hsim is shipped ready to run on Windows systems. Running under Linux or other UNIX system will require recompilation. Windows InstallationCreate a new folder (directory) somewhere and place hsim.zix into that folder. Rename hsim.zix to hsim.zip. Double-click on hsim.zip file and select “Extract here”. This will install the program, its binaries and some other stuff into the folder. NOTE: If you have cygwin installed, delete the copy of cygwin1.dll that came off the zip file and run the program from a cygwin window. If you do not have cygwin installed then run the simulator from a dos prompt in this directory. Linux InstallationFollow these simple instructions to build and run hsim:
You will also need a Linux version of cpropep. This should be installed in the cpropep subdirectory. Be sure to use the propellant.dat file that comes with this distribution, or to adjust the propellant line numbers found in fuel.csv to match the correct line numbers in your propellant.dat file. Test RunsThe directory hybrid\TEST contains a sample input file, test.input. The remaining files in the test directory were created using
The program as distributed should be able to regenerate these files byte for byte. This simple test may only work if run from the “hybrid” directory. Unfortunately there are some path names wired into the linkage between hsim and cpropep. These paths are defined in hybrid/cpp.h. The windows version also needs to find the cygwin1.dll file, which may need to be in the current directory. The program ships with the cached cpropep data used by test.input. Any changes to fuel or nozzle parameters will require the –N option to create a new cpropep data mesh. |